<?php

namespace app\merchant\controller;

use app\common\model\GoodsCategory as GoodsCategoryModel;

class GoodsCategory extends Common
{
	public function showlist()
	{
		$data = GoodsCategoryModel::getParentCategory();
		// return  json($data);
		return view('showlist', ['data'=>$data]);
	}



	// 获取一个主分类的所有子分类

	public function childs()
	{
		$catId = (int)input('param.catId');
		if($catId)
		{
			$data = []; 
			$catIds = GoodsCategoryModel::getOnlyChilds($catId);
			foreach($catIds as $k => $v)
			{
				$result = GoodsCategoryModel::field('goods_category_id,goods_category_name,goods_category_parent_id')->find($v)->toArray();
				$data[] = $result;
			}

		}
		return returnJson(1, '', $data);
	}



	public function update()
	{
		$data = GoodsCategoryModel::getParentCategory();
		return view('update', ['data'=>$data]);
	} 
}